package com.hongxun.design;

import android.app.Activity;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by zerdoor_pc on 2016/6/23.
 */
public class MyAPPActivity  {
    private List<Activity> mList = new LinkedList<Activity>();
    private static MyAPPActivity instance;
    private MyAPPActivity() {
    }
    public static MyAPPActivity getInstance() {
        if (instance == null) {
            instance = new MyAPPActivity();
        }
        return instance;
    }
    // add Activity
    public void addActivity(Activity activity) {
        mList.add(activity);
    }

    public void exit() {
        try {
            for (Activity activity : mList) {
                if (activity != null)
                    activity.finish();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            System.exit(0);
        }
    }
    public void clear(Activity mactivity) {
        try {
            for (Activity activity : mList) {
                if (activity != null&&activity!=mactivity)
                    activity.finish();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            //System.exit(0);
        }
    }

}
